﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;

namespace WebSys.UI.Control.ZhengShou
{
    public class ZS_SQQZZXBControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            Panel panel1 = (Panel)FindControl("panel1");
            if (!base.Page.IsPostBack)
            {
                Persistence1.Table = "ZS_QZSQB";
                Persistence1.Key = "CID";
                Persistence1.KeyValue = HttpContext.Current.Request["CID"];
                Persistence1.ConnStr = _EluZSDataProvider.GetConnectionString();
            }
            Persistence1.BindControl = panel1;

            Button btn_Insert = (Button)FindControl("btn_Insert");
            btn_Insert.Click += new EventHandler(btn_Insert_Click);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            TextBox txtQWSX = (TextBox)FindControl("txtQWSX");
            TextBox txtCASEID = (TextBox)FindControl("txtCASEID");
            TextBox txt申请执行人 = (TextBox)FindControl("txt申请执行人");
            TextBox txt申请代表人 = (TextBox)FindControl("txt申请代表人");
            TextBox txt被申请人 = (TextBox)FindControl("txt被申请人");
            MPCalendar txt征收补偿决定送达时间 = (MPCalendar)FindControl("txt征收补偿决定送达时间");
            TextBox txt被申请代表人地址 = (TextBox)FindControl("txt被申请代表人地址");
            TextBox FWDZ = (TextBox)FindControl("FWDZ");
            TextBox txtCID = (TextBox)FindControl("txtCID");
            TextBox txtID = (TextBox)FindControl("txtID");
            string strcid = base.Page.Request["CID"];
            if (!string.IsNullOrEmpty(strcid)) { 
                txtCID.Text = strcid;
                EluZSProvider.CASE_REGISTER caseregister = _EluZSDataProvider.GetCASE_REGISTER(strcid);
                txtQWSX.Text = caseregister.QWSX;
                txtCASEID.Text = caseregister.CASEID;
                txt申请执行人.Text = caseregister.SQR;
                txt申请代表人.Text = caseregister.SQRDLR;
                txt被申请人.Text = caseregister.BSQR;
                if (caseregister.CAIJUESONGDADATE.HasValue) { txt征收补偿决定送达时间.Text = caseregister.CAIJUESONGDADATE.Value.ToShortDateString(); }
                txt被申请代表人地址.Text = caseregister.FWDZ;
                FWDZ.Text = caseregister.FWDZ;

                string tt = _EluZSDataProvider.GetSomeStr("ZS_QZSQB", "id", "cid", strcid);
                if (string.IsNullOrEmpty(tt)) { txtID.Text = System.Guid.NewGuid().ToString().Replace("-", "").ToUpper(); } else { txtID.Text = tt; }
            }
        }
        protected void btn_Insert_Click(object sender, EventArgs e)
        {
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            Persistence1.Update();
            HttpContext.Current.Response.Redirect("ZS_SQQZZXB.aspx?CID=" + base.Page.Request["CID"] + "&IID=" + base.Page.Request["IID"]);
        }
    }
}


